<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head>
	<meta charset="UTF-8"/>
	<link rel="stylesheet" th:href="@{css/bootstrap.min.css}"/>
	<style type="text/css">
		body {
			padding-top: 50px;
		}

		.starter-template {
			padding: 40px 15px;
			text-align: center;
		}
	</style>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
	<div class="container">
		<div class="navbar-header">
			<a class="navbar-brand" href="#">Spring Security演示</a>
		</div>
		<div id="navbar" class="collapse navbar-collapse">
			<ul class="nav navbar-nav">
				<li><a th:href="@{/}">首页</a></li>
				<li><a th:href="@{http://www.baidu.com}">百度</a></li>
				<li><a th:href="@{/admin}">管理员页面</a></li>
			</ul>
		</div>
	</div>
</nav>
<div class="container">
	<!-- 通过sec:authentication=”name”我们可以获取当前用户名  -->
	<div align="center">
		<span class="label label-default" sec:authentication="name"></span>
	</div>
	<div class="starter-template">
		<h1 th:text="${msg.title}"></h1>
		<p class="bg-primary" th:text="${msg.content}"></p>

		<!-- sec:authorize="hasRole('ADMIN')表示当前用户角色为ROLE_ADMIN的话显示里边的内容 -->
		<div sec:authorize="hasRole('ADMIN')">
			<p class="bg-info" th:text="${msg.extraInfo}"></p>
		</div>

		<!-- sec:authorize="hasRole('USER')表示当前用户角色为ROLE_USER的话显示该DIV里边的内容 -->
		<div sec:authorize="hasRole('USER')">
			<p class="bg-info">无更多显示信息</p>
		</div>
		<form th:action="@{/logout}" method="post">
			<input type="submit" class="btn btn-primary" value="注销"/>
		</form>
	</div>
</div>
</body>
</html>